home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 …ember: Reference Library / Dev.CD Dec 00 RL Disk 1.toast / pc / technical documentation / develop / develop issue 29 / develop issue 29 code / acgis in c / acgi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-08  |  6.5 KB  |  217 lines

  1. #ifndef __ACGI__
  2. #define __ACGI__
  3.  
  4. #include <Threads.h>
  5.  
  6. void ACGILog(char *msg);
  7.  
  8. // -----------------------------------------------------
  9.  
  10. enum {
  11.     errWWWNoMemory = -1,
  12.     errWWWUnexpected = -2,
  13.     errWWWRefused = -3,
  14.     errWWWTooBusy = -4
  15. };
  16.  
  17. // -----------------------------------------------------
  18.  
  19. typedef struct WWWRequestRecord {
  20.     char *pathArgs;
  21.     char *username;
  22.     char *password;
  23.     char *fromUser;
  24.     char *clientAddress;
  25.     char *serverName;
  26.     char *serverPort;
  27.     char *scriptName;
  28.     char *contentType;
  29.     char *referer;
  30.     char *userAgent;
  31.     char *action;
  32.     char *actionPath;
  33.     char *method;
  34.     char *clientIP;
  35.     char *fullRequest;
  36.     char *connectionID;
  37.  
  38.     char *searchArgs;
  39.     char *postArgs;
  40.     
  41.     long searchNum;
  42.     Handle searchNames;
  43.     Handle searchValues;
  44.  
  45.     long postNum;
  46.     Handle postNames;
  47.     Handle postValues;
  48.  
  49.     Handle storage;
  50.     Handle response;
  51.     
  52.     AppleEvent *event;    // Just in case you need to get at the raw information
  53.                         // in the event...
  54.     
  55.     Boolean isLocked;
  56. } WWWRequestRecord, *WWWRequest;
  57.  
  58. // -----------------------------------------------------
  59.  
  60. void ACGIFatal(char *reason);
  61. void ACGIShutdown(void);
  62. Boolean ACGIIsShuttingdown(void);
  63. Boolean ACGIRefuse(Boolean refuse);
  64. unsigned long ACGIGetRunningThreads(void);
  65. unsigned long ACGIGetMaxThreads(void);
  66. void ACGISetMaxThreads(unsigned long newThreads);
  67. void ACGIGetSleeps(long *whenThreads, long *whenIdle);
  68. void ACGISetSleeps(long whenThreads, long whenIdle);
  69. long ACGIGetWNEDelta(void);
  70. void ACGISetWNEDelta(long newDelta);
  71. void ACGIGetThreadParams(Size *stack, ThreadOptions *options);
  72. void ACGISetThreadParams(Size stack, ThreadOptions options);
  73. const char *ACGIGetHTTPHeader(void);
  74.  
  75. // -----------------------------------------------------
  76.  
  77. typedef enum WWWParameter {
  78.     p_path_args = 0,
  79.     p_username,
  80.     p_password,
  81.     p_from_user,
  82.     p_client_address,
  83.     p_server_name,
  84.     p_server_port,
  85.     p_script_name,
  86.     p_content_type,
  87.     p_referer,
  88.     p_user_agent,
  89.     p_action,
  90.     p_action_path,
  91.     p_method,
  92.     p_client_ip,
  93.     p_full_request,
  94.     p_connection_id
  95. } WWWParameter;
  96.  
  97. // [1]    Lock down 'request' parameters before accessing contents.
  98.  
  99. Boolean HTTPLockParams(WWWRequest r);
  100.  
  101. // [2]    Unlock the request parameters.
  102.  
  103. void HTTPUnlockParams(WWWRequest r);
  104.  
  105. // [3]    Get a pointer to one of the parameter strings.
  106. //        This leaves 'r' locked.
  107.  
  108. const char *HTTPGetParam(WWWRequest r, WWWParameter par);
  109.  
  110. /// [4] Get the integer value of a parameter. Result is returned
  111. //         in 'i'. Function returns 'false' if the parameter is
  112. //         not an integer.
  113.  
  114. Boolean HTTPGetLong(WWWRequest r, WWWParameter par, long *i);
  115.  
  116. // [5]    Copy parameter text into character variable 'result'. Length of your character
  117. //        variable is in 'len', the actual length of the parameter is returned in
  118. //         'actualLen'. Function return 'false' if the parameter identifier 'par' is invalid.
  119.  
  120. Boolean HTTPCopyParam(WWWRequest r, WWWParameter par, char *result, long len, long *actualLen);
  121.  
  122. // [6/7]    Get number of SEARCH/POST arguments.
  123.  
  124. long HTTPGetNumSrchArgs(WWWRequest r);
  125. long HTTPGetNumPostArgs(WWWRequest r);
  126.  
  127. // [8/9]    Get a SEARCH/POST argument by absolute position. 'index' is between
  128. //          1 and the total number of SEARCH/POST arguments. 'name' receives the
  129. //            name of the argument at position 'index' and 'value' receives the value.
  130. //            The lengths of the character arrays 'name' and 'value' are in 'nameLen'
  131. //            and 'valueLen'. The actual lengths of the items are returned in
  132. //            'actualNameLen' and 'actualValueLen'. Function returns 'false' if 'index'
  133. //            is out of range.
  134.  
  135. Boolean HTTPGetSrchArgAt(WWWRequest r, long index, char *name,
  136.                         long nameLen, long *actualNameLen, char *value,
  137.                         long valueLen, long *actualValueLen);
  138.  
  139. Boolean HTTPGetPostArgAt(WWWRequest r, long index, char *name,
  140.                         long nameLen, long *actualNameLen, char *value,
  141.                         long valueLen, long *actualValueLen);
  142.  
  143. // [10/11]    Get number of SEARCH/POST arguments that have the same field
  144. //            name 'name'. Number is returned in 'numValues'. Function return
  145. //            'false' if there is no SEARCH/POST argument called 'name'.
  146.  
  147. Boolean HTTPGetSrchArgCount(WWWRequest r, char *name, long *numValues);
  148. Boolean HTTPGetPostArgCount(WWWRequest r, char *name, long *numValues);
  149.  
  150. // [12/13]    Try to get instance 'index' of a multi-valued SEARCH/POST argument.
  151. //            Function returns empty string if 'index' is out of range or if 'name' doesn't
  152. //            exist. Function leaves 'r' locked on exit.
  153.  
  154. const char *HTTPGetMultipleSrchArg(WWWRequest r, char *name, long index);
  155. const char *HTTPGetMultiplePostArg(WWWRequest r, char *name, long index);
  156.  
  157. // [14/15]    Get integer value of instance 'index' of a multi-valued SEARCH/POST
  158. //            argument called  'name'. Function returns value in 'i'. Function returns
  159. //            'false' if 'index' is out of range or the argument is not an integer.
  160.  
  161. Boolean HTTPGetLongMultipleSrchArg(WWWRequest r, char *name, long index, long *i);
  162. Boolean HTTPGetLongMultiplePostArg(WWWRequest r, char *name, long index, long *i);
  163.  
  164. // [16/17]    Copy the contents of instance 'index' of a multi-valued SEARCH/POST
  165. //            argument called 'name'. Function returns text in 'value'. Length of 'value'
  166. //            string is in 'len', actual length of the value string is returned in 'actualLen'
  167. //             Function returns 'false' if 'index' is out of range or 'name' does not exist.
  168.  
  169. Boolean HTTPCopyMultipleSrchArg(WWWRequest r, char *name, long index, char *value, long len, long *actualLen);
  170. Boolean HTTPCopyMultiplePostArg(WWWRequest r, char *name, long index, char *value, long len, long *actualLen);
  171.  
  172. // -----------------------------------------------------
  173.  
  174. // [1]    Get the handle that holds the HTML response page.
  175.  
  176. Handle HTMLGetResponseHandle(WWWRequest r);
  177.  
  178. // [2]    Clear out the current response page (except for the
  179. //        HTTP header, and start over.
  180.  
  181. OSErr HTMLClearPage(Handle r);
  182.  
  183. // [3]    Append contents of handle 'h' to response page.
  184.  
  185. OSErr HTMLAppendHandle(Handle r, Handle h);
  186.  
  187. // [4]    Append TEXT resource (ID=iTEXTResID) to response page.
  188.  
  189. OSErr HTMLAppendTEXT(Handle r, long iTEXTResID);
  190.  
  191. // [5]    Append STR resource (ID=iSTRResID) to the response page.
  192.  
  193. OSErr HTMLAppendString(Handle r, long iSTRResID);
  194.  
  195. // [6]    Append string at location 'index' in STR# resource
  196. //        (ID=iSTRResID) to the response page.
  197.  
  198. OSErr HTMLAppendIndString(Handle r, long iSTRResID, long index);
  199.  
  200. // [7]    Append local file to response page.
  201.  
  202. OSErr HTMLAppendFile(Handle r, char *localFileName);
  203.  
  204. // [8]    Append C-string to response page.
  205.  
  206. OSErr HTMLAppendCString(Handle r, char *cString);
  207.  
  208. // [9]    Append Pascal-string to response page.
  209.  
  210. OSErr HTMLAppendPString(Handle r, StringPtr pString);
  211.  
  212. // [10]    Append text buffer of length 'len' to response page.
  213.  
  214. OSErr HTMLAppendBuffer(Handle r, char *buffer, long len);
  215.  
  216. #endif
  217.